package org.groupg.practice;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class JsoupExample3 {
    public static void main(String[] args) throws Exception {
        Document doc = Jsoup.connect("https://news.ycombinator.com").get();

        // 提取新闻标题（Hacker News 示例）
        for (Element item : doc.select(".titleline > a")) {
            String title = item.text();
            String url = item.attr("abs:href"); // 绝对路径
            System.out.println(title + "\n链接: " + url + "\n");
        }
    }
}
